package com.njwb;

import cn.njwb.config.BussinessConfig;
import com.njwb.annotation.EnableAutoImports;
import com.njwb.selector.SpringBootImportSelector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

import java.util.Date;

@SpringBootApplication
//@ComponentScan("cn.njwb")
//@Import(BussinessConfig.class)
//@Import(SpringBootImportSelector.class)
@EnableAutoImports
public class SpringBootBeanApplication {
    public static void main(String[] args) {
        //Spring Boot启动后，会初始化容器
        //扫描到@Bean注解时，会创建对象，并存储到IoC容器中
        ApplicationContext context = SpringApplication.run(SpringBootBeanApplication.class, args);
//        System.out.println(context.getBean(Date.class));
//        System.out.println(context.getBean("date"));
//        System.out.println(context.getBean("beanDate"));
//        System.out.println(context.getBean("person"));
        System.out.println(context.getBean("obj"));
    }
//    @Bean//bean的默认名字就是方法名
//    public Date date(){
//        return new Date();
//    }
}
